package com.atguigu.web.admin.controller;

import com.atguigu.commo.result.Result;
import com.atguigu.model.domain.PaymentType;
import com.atguigu.web.admin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name="支付方式管理模块")
@RequestMapping("/admin/payment")
public class PaymentTypeController {
    @Resource
    PaymentTypeService paymentTypeService;
    @Operation(summary = "根据id删除支付方式")
    @DeleteMapping("deletedById")
    public Result deleteById(@RequestParam("id")Long id){
        return Result.build(paymentTypeService.removeById(id));
    }
    @GetMapping("/list")
    @Operation(summary = "查询支付方式")
    public  Result<List<PaymentType>> list(){
        return Result.ok(paymentTypeService.list());
    }
    @Operation(summary = "新增或更新")
    @PatchMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody PaymentType paymentType){
        boolean b = paymentTypeService.saveOrUpdatePaymentType(paymentType);
        return Result.build(b);
    }
}
